<template>
	<view class="scanPopup">
		<uni-popup ref="popup" type="center" :is-mask-click="isMaskClick" :mask-background-color="maskBackgroundColor">
			<view class="popup_openMember_content">
				<view class="header">提示 </view>
				<view class="content">
					<view class="popup__openMember">
						<text v-if="tryOutStatus">当前剩余{{ num }}次试用</text> <br>
						<text >是否开通会员?</text>
					</view>										
				</view>
				<view class="btn">
					<uni-row>
						<uni-col :span="tryOutStatus?8:12" class="itemSpan itemSpan0">
							<view class="popup_btn popup_btn_disable" @click="cancel">取消</view>
						</uni-col>
						<uni-col :span="tryOutStatus?8:12" class="itemSpan itemSpan1">
							<view class="popup_btn" @click="confirm">去开通</view>
						</uni-col>
						<uni-col :span="tryOutStatus?8:12" class="itemSpan itemSpan2" v-if="tryOutStatus">
							<view class="popup_btn" @click="confirm_tryout">试用</view>
						</uni-col>
					</uni-row>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		mapGetters,
		mapMutations,
		mapActions
	} from 'vuex'

	export default {
		data() {
			return {
				isMaskClick: false,
				maskBackgroundColor: "rgba(0,0,0,0.3)",
				popup_Type: null,
				filesType: null,
				listLength: 0,
				num: null
			}
		},
		computed: {
			...mapGetters(['tryOutStatus', "tryOutNum"])
		},

		methods: {
			...mapMutations(["updataTryOutStatus", "updataTryOutNum"]),
			popupOpen(data) {
				this.$nextTick(() => {
					this.num = this.tryOutNum
					this.$refs.popup.open()

				})
			},
			cancel() {
				this.$refs.popup.close()
			},
			confirm() {
				this.$refs.popup.close()
				this.$emit("goMember")
			},
			confirm_tryout() {
				this.$refs.popup.close()
				setTimeout(() => {
					if (this.num > 1) {
						this.num--;
						this.updataTryOutNum(this.num)
					} else {
						this.updataTryOutStatus(false)
					}
					this.$emit("menber_tryout")
				}, 300)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.popup_openMember_content {
		background: #ffffff;
		border-radius: 34.62rpx;
		width: 519.23rpx;
		height: 394.23rpx;
		overflow: hidden;

		.header {
			text-align: center;
			height: 115.38rpx;
			font-size: 32rpx;
			color: #ffffff;
			line-height: 115.38rpx;
			font-size: 32.69rpx;
			font-weight: 500;
			background: url(../../static/images/resetHeaderBg.png) center center no-repeat;
			background-size: 100% 100%;
		}

		.content {
			font-size: 30.77rpx;
			font-weight: 400;
			color: #666666;
			height: 146.15rpx;
			
			padding-top: 38.46rpx;
			text-align: center;
		}

		.btn {
			height: 92.31rpx;
			border-top: 2rpx solid #D9D9D9;

			.itemSpan {

				text-align: center;
				height: 92.31rpx;
				line-height: 92.31rpx;
				font-size: 30.77rpx;
				font-weight: 400;
				color: #999999;
			}

			.itemSpan0 {
				border-right: 2rpx solid #D9D9D9;
			}

			.itemSpan1 {
				color: #226CFF;
			}

			.itemSpan2 {
				border-left: 2rpx solid #D9D9D9;
			}

		}
	}
</style>